import { createSlice,  } from '@reduxjs/toolkit'




export const personListSlice = createSlice({
  name: 'personListSlice',
  initialState: {
    list: [{
      id: 1,
      name: "张三",
      code: 123456789087654,
      state: false
    }, {
      id: 2,
      name: "李四",
      code: 123456789087654,
      state: false
    },{
      id: 3,
      name: "王五",
      code: 123456789087654,
      state: false
    }]
  },
  reducers: {
    changeState(state, action) {
      const item = state.list.find(item => item.id === action.payload.id)
      item.state = !item.state
    }
  },  
})

export const { changeState } = personListSlice.actions


